package com.bwie.controller;

import com.bwie.bean.User;
import com.bwie.service.CanteenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {

    @Autowired
    CanteenService canteenService;

    @RequestMapping("login.do")
    public String login(User user, HttpSession session){
        User user1=canteenService.listUser(user);
        if (user1!=null){
            session.setAttribute("user",user);
            return "redirect:list.do";
        }else {
            return "redirect:index.jsp";
        }
    }
}
